package org.lilystudio.veryftp.util;

public class WordUtil {
	
	
	public static String parse(String keyword){
		keyword=keyword.replaceAll("-()", " ");
		keyword=keyword.replaceAll("_", " ");
		
		StringBuilder result=new StringBuilder();
		int i=0;
		while(i<keyword.length()){
			if(i==0){			
				result.append(keyword.charAt(i));
				i++;
				continue;
			}
			
			if(keyword.charAt(i)=='.'&&Character.isLetter(keyword.charAt(i+1)) || keyword.charAt(i)=='.'&&Character.isLetter(keyword.charAt(i-1))){
				result.append(' ');
				i++;
				continue;
			}
			
			if(Character.isDigit(keyword.charAt(i)) && Character.isLetter(keyword.charAt(i-1)) ||					
				Character.isDigit(keyword.charAt(i-1)) && Character.isLetter(keyword.charAt(i))){
				result.append(" "+keyword.charAt(i));			
			}
			else{
				result.append(keyword.charAt(i));
			}
			i++;
		}
		return result.toString();
	}
}
